package com.zhzy.controller;

import com.github.pagehelper.PageInfo;
import com.zhzy.api.dao.UserDao;
import com.zhzy.common.pojo.User;
import com.zhzy.api.fegin.service.FMemberService;
import com.zhzy.common.util.JacksonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by zj on 2017/7/11.
 */
@RestController
public class CartController {
    @Autowired
    private FMemberService fMemberService;

    @Value("${server.port}")
    String port;

    @RequestMapping(value = "/addCart")
    public String addCart(@RequestParam String name){
        //String rtn = "进入cart服务,调用member服务的方法";
       String rtn =fMemberService.findMember("cart find member");
        return rtn+"this is cartService feign addCart "+name+",i am from port:" +port;
    }
    @Autowired
    private UserDao usrDao;
    @RequestMapping(value = "/all")
    public String findAll(){
        List<User> r = usrDao.getAll();
        return JacksonUtil.toJSONString(r);
    }

    @RequestMapping(value = "/allPage")
    public PageInfo<User> getAllPage() {
        List<User> countryList = usrDao.getAll();
        return new PageInfo<User>(countryList);
    }
}
